package algotithm.weekendrace.biweeklycontest51.test1;

/**
 * @author 25068
 * @Date 2021/5/1 22:26
 * @Title 5730. 将所有数字用字符替换
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        String s = "a1b2c3d4e";
        String s1 = solution.replaceDigits(s);
        System.out.println(s1);
    }

    public String replaceDigits(String s) {
        char[] c = s.toCharArray();
        for (int i = 1; i < c.length; i++) {
            if (Character.isDigit(c[i])) {
                c[i] = (char) (c[i-1] + c[i] - '0');
            }
        }
        return new String(c);
    }

}
